@extends('admin.layout')
@section('title','新增用户')
@section('content')
    <div class="app_content_div" id="app_content_div_301Index">
        <h3>新增用户</h3>
        <form class="form-horizontal" method="post" action="/adm/user">
            <div class="form-group">
                <label for="name" class="col-sm-2 control-label"><span style="color:red;">*</span>用户名</label>
                <div class="col-sm-10">
                    <input type="text" class="form-control" id="name" name="name">
                </div>
            </div>
            <div class="form-group">
                <label for="email" class="col-sm-2 control-label"><span style="color:red;">*</span>邮箱</label>
                <div class="col-sm-10">
                    <input type="email" class="form-control" id="email" name="email">
                </div>
            </div>
            <div class="form-group">
                <label for="password" class="col-sm-2 control-label"><span style="color:red;">*</span>密码</label>
                <div class="col-sm-10">
                    <input type="password" class="form-control" id="password" name="password">
                </div>
            </div>
            <div class="form-group">
                <label for="password" class="col-sm-2 control-label"><span style="color:red;">*</span>确认密码</label>
                <div class="col-sm-10">
                    <input type="password" class="form-control" id="password_confirmation" name="password_confirmation">
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-offset-2 col-sm-10">
                    <button type="button" onclick="create()" class="btn btn-default">确定</button>
                </div>
            </div>
        </form>
        <script>
            function create(){
                name = $('#name').val();
                password = $('#password').val();
                password_confirmation = $('#password_confirmation').val();
                email = $('#email').val();

                $.post(
                    '/adm/user',
                    {'name':name,'email':email,'password':password,'password_confirmation':password_confirmation,'_token':'{{csrf_token()}}'},
                    function (data){
                        if(data.success){
                            alert(data.msg);
                            location.href='/adm/user';
                        }else{
                            alert(data.msg);
                        }
                    },
                    'json'
                );
            }
        </script>
@endsection

